<template>
  <div v-if="third[0]">
    <div class="margin">
      <img :src="third[0].bannerImgSrc" alt="">
    </div>
    <div class="chairs margin">
      <div class="single-chair" v-for="item in third[1].banners" :key="item.id" @click="handleGroup(item.bannerLinkTargetId)">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="chairs margin">
      <div class="single-chair" v-for="item in third[2].banners" :key="item.id" @click="handleGroup(item.bannerLinkTargetId)">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="sofa margin">
      <div class="single-sofa" :key="item.id" v-for="item in third[3].banners">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="sofa margin">
      <div class="single-sofa" :key="item.id" v-for="item in third[4].banners">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="sofa margin">
      <div class="single-sofa" :key="item.id" v-for="item in third[5].banners">
        <img :src="item.bannerImgSrc" alt="">
      </div>
    </div>
    <div class="gap margin">
      <img :src="third[6].bannerImgSrc" alt="">
    </div>
    <div class="gap margin">
      <img :src="third[7].bannerImgSrc" alt="">
    </div>
    <fourdata></fourdata>
  </div>
</template>

<script>
import axios from 'axios'
import fourdata from './four'
export default {
  data () {
    return {
      third: []
    }
  },
  mounted () {
    window.onscroll = () => {
      if ((document.documentElement.scrollTop + document.documentElement.clientHeight) === document.documentElement.scrollHeight) {
        axios.get('/v2/page?pageId=1&tabId=1&currentPage=3&pageSize=8&_=1583391525114').then(res => {
          this.third = res.data.data.modules.map(item => item.moduleContent)
        })
      }
    }
  },
  destroyed () {
    window.onscroll = null
  },
  components: {
    fourdata
  },
  methods: {
    handleGroup (targetId) {
      this.$router.push(`/productGroup/${targetId}`)
    }
  }
}
</script>

<style lang="scss" scoped>
img {
  width: 100%;
}
.sofa{
  display: flex;
  background: white;
  padding: 30px 15px 10px 15px;
  justify-content: space-between;
  .single-sofa{
    width: 48%;
  }
}
.chairs{
  display: flex;
  padding:50px 15px 10px 15px;
  background: white;
  justify-content: space-between;
  .single-chair{
    width: 30%;
  }
}
</style>
